#ifndef VENUS_SHADOW_VOLUME_SHADOW_VOLUME_DEMO_H
#define VENUS_SHADOW_VOLUME_SHADOW_VOLUME_DEMO_H

#include "common/venus.h"
#include "ui/glut_window.h"
#include "graphics/camera.h"
#include "graphics/fps_counter.h"
#include "nvModel/nvModel.h"

namespace venus {
class AopDemo : public GlutWindow {
public:
  AopDemo(); 
  ~AopDemo();
  bool Initialize();
  void OnIdle();
  void OnDisplay();
  void OnResize(int width, int height);
  void OnKeyboard(unsigned char key, int x, int y);
  void OnSpecialKey(int key, int x, int y);
private:
  bool InitPeelingRenderTargets();
  void DeletePeelingRenderTargets();
  void ReleaseResources();
  void LoadShaders();
  void RenderDepthPeeling();
  void TransformToBits();
  void Visualize();
private:
  OrbitPerspectiveCameraGL camera_;
  OrbitPerspectiveCameraGL light_;
  FpsCounter fps_counter_;
  nv::Model *model_;
  ImageTextureGL *bits_tex_;
  ImageTextureGL *min_max_depth_tex_;
  ImageTextureGL *depth_texs_[8];
  ProgramGLSL *min_max_program_;
  ProgramGLSL *peel_program_;
  ProgramGLSL *to_bits_program_;
  ProgramGLSL *visualize_program_;
  RenderDeviceFBO *render_device_;
  GLenum mrt_[8];
  ModelGL *model_gl_;
  TriangleMesh *mesh_;
  GLuint quad_display_list_;
};
} // namespace venus

#endif // VENUS_SHADOW_VOLUME_SHADOW_VOLUME_DEMO_H
